import React = require("react");
import { component } from "components/common/component";

export interface Props {
    html: string
    emptyText: string
}

const defaultEmptyText = '请设置 HTML';

@component({ displayName: "HTML", icon: "icon-text-width", introduce: "用于创建 HTML 文本" })
export class HTML extends React.Component<Props> {
    render() {
        let { html } = this.props;
        if (!html) {
            let emptyText = this.props.emptyText || defaultEmptyText;
            html = `<div class="text-center" style="padding:20px 0 20px 0">${emptyText}</div>`;
        }
        return <div dangerouslySetInnerHTML={{ __html: html }} />;
    }
}